//
//  MyCollectionViewCell.m
//  我的测试
//
//  Created by eliot on 16/8/5.
//  Copyright © 2016年 aleven. All rights reserved.
//

#import "MyCollectionViewCell.h"


@interface MyCollectionViewCell ()

@property (weak, nonatomic) IBOutlet UILabel *contenLb;

@property (weak, nonatomic) IBOutlet UILabel *nameLb;

@property (weak, nonatomic) IBOutlet UILabel *descLb;

@property (weak, nonatomic) IBOutlet UIImageView *headIconIV;


@property (weak, nonatomic) IBOutlet NSLayoutConstraint *contentLbH;


@end



@implementation MyCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.myImage.layer.cornerRadius = 4;
    self.myImage.layer.masksToBounds = YES;
    self.headIconIV.layer.cornerRadius = self.headIconIV.frame.size.width / 2.0;
    self.headIconIV.layer.masksToBounds = YES;
    
    self.contenLb.textColor = ThreeColor;
    self.descLb.textColor = nineColor;
    self.nameLb.textColor = zeroColor;
    
    [self setupLineSpacing];
    
}

//设置label的行间距
- (void)setupLineSpacing {
    
    NSString * cLabelString = @"456as465sad456sda654as456456das645as,asdasd456465wq465wqe546wqe456ewq456";
    self.contenLb.numberOfLines = 2;
    self.contenLb.font = [UIFont systemFontOfSize:12];
    CGFloat wid = (Swidth - 30) / 2.0 - 16;
    
//    NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:cLabelString];
//    NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
//    [paragraphStyle1 setLineSpacing:6];
//    [attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [cLabelString length])];
//    [attributedString1 addAttribute:NSFontAttributeName
//     
//                              value:[UIFont systemFontOfSize:12.0]
//     
//                              range:NSMakeRange(0, [cLabelString length])];
    
    
  
    CGRect rr = [cLabelString boundingRectWithSize:CGSizeMake(wid, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:self.contenLb.font} context:nil];
    
    
//    CGSize siz=CGSizeMake(wid, MAXFLOAT);
//    
//    CGRect rr = [attributedString1 boundingRectWithSize:siz options:NSStringDrawingUsesLineFragmentOrigin context:nil];
//    
//    
    if (rr.size.height > 26) {
        
        
        self.contentLbH.constant = 33 + 6;
    }else {
        self.contentLbH.constant = 19;
    }
    
    self.contenLb.text = cLabelString;
//    [self.contenLb setAttributedText:attributedString1];
//    [self.contenLb sizeToFit];
//    NSLog(@"%f, %@", self.contentLbH.constant, attributedString1);
    
}

@end
